<?php

class Jabatan{
	private $id;
	private $jabatan;
	private $eselon;
	
	function __construct(){}
	
	function setId($id){
		$this->id = $id;
	}
	
	function setJabatan($jabatan){
		$this->jabatan = $jabatan;
	}
	
	function setEselon($eselon){
		$this->eselon = $eselon;
	}
	
	function getId(){
		return $this->id;
	}
	
	function getJabatan(){
		return $this->jabatan;
	}
	
	function getEselon(){
		return $this->eselon;
	}

}


class Daftar_jabatan{

	function __construct(){}
	
	function getAll(){
		
		$sql="
		select *
		from
		jabatan
		";
		
		$list_jabatan = array();
		
		$data = mysql_query($sql);
		if($data){
			while($row = mysql_fetch_assoc($data)){
			
				$jabatan = new Jabatan();
				$jabatan->setId($row['kd_jabatan']);
				$jabatan->setJabatan($row['jabatan']);
				$jabatan->setEselon($row['eselon']);
								
				$list_jabatan[] = $jabatan;
			}
		}	
		return $list_jabatan;
	}
	
	function getPejabat(){
		
		$sql="
		select *
		from
		jabatan
		where upper(jabatan) != 'upper(pelaksana)'
		";
		
		$list_jabatan = array();
		
		$data = mysql_query($sql);
		if($data){
			while($row = mysql_fetch_assoc($data)){
			
				$jabatan = new Jabatan();
				$jabatan->setId($row['kd_jabatan']);
				$jabatan->setJabatan($row['jabatan']);
				$jabatan->setEselon($row['eselon']);
								
				$list_jabatan[] = $jabatan;
			}
		}	
		return $list_jabatan;
	}
	
	function getPejabatByEselon($eselon){
		
		$sql="
		select *
		from
		jabatan
		where eselon = '$eselon'
		";
		
		$list_jabatan = array();
		
		$data = mysql_query($sql);
		if($data){
			while($row = mysql_fetch_assoc($data)){
			
				$jabatan = new Jabatan();
				$jabatan->setId($row['kd_jabatan']);
				$jabatan->setJabatan($row['jabatan']);
				$jabatan->setEselon($row['eselon']);
								
				$list_jabatan[] = $jabatan;
			}
		}	
		return $list_jabatan;
	}
	
	function getById($id){
		
		$sql="
		select *
		from
		jabatan
		where kd_jabatan = '$id'
		";
		
		
		$data = mysql_query($sql);
		if($data){
			while($row = mysql_fetch_assoc($data)){
			
				$jabatan = new jabatan();
				$jabatan->setId($row['kd_jabatan']);
				$jabatan->setJabatan($row['jabatan']);
			
			}
		}	
		return $jabatan;
	}
}